//
//  SAAberrations.m
//  ronchigram
//
//  Created by James LeBeau on 5/26/10.
//  Copyright 2010 subangstrom. All rights reserved.
//
//	Aberration values should all be in angstroms!

#import "SAAberration.h"


@implementation SAAberration

@synthesize n;
@synthesize m;
@synthesize label;
@synthesize Cnma;
@synthesize Cnmb;
@synthesize max;
@synthesize min;
@synthesize symRange;

- (id) init
{
	self = [super init];
	if (self != nil) {
		
		n = 0;
		m = 0;
		Cnma = 0;
		Cnmb = 0;
		max = 10000;
		min = -10000;
		label = @"Unspecified";
		symRange = YES;
				 
			 
		aberrDict = [[NSMutableDictionary alloc] init];
	}
	return self;
}


+ (SAAberration*) aberrationWithN: (int) nVal 
								M: (int) mVal 
							 Cnma: (float) cnmaVal 
							 Cnmb: (float) cnmbVal;
{
	SAAberration* newAberration = [[SAAberration alloc] init];
	
/*	NSMutableDictionary *dict = [newAberration coefficients];
	
	[dict setObject:[NSNumber numberWithInt:nVal] forKey:kSAn];
	[dict setObject:[NSNumber numberWithInt:mVal] forKey:kSAm];
	[dict setObject:[NSNumber numberWithInt:cnmaVal] forKey:kSACnma];
	[dict setObject:[NSNumber numberWithInt:cnmbVal] forKey:kSACnmb];
*/	
	newAberration.n = nVal;
	newAberration.m = mVal;
	newAberration.Cnma = cnmaVal;
	newAberration.Cnmb = cnmbVal;
	
	 
	return newAberration;
}

- (void) setMin: (float) newMin Max: (float) newMax{
	
	min = newMin;
	max = newMax;
	
}

- (NSMutableDictionary*) coefficients{
	return aberrDict;
}

- (id) aberrationForKey: (id) key{
	return [aberrDict objectForKey:key];
	
}

- (void) setAberration: (NSNumber *)  coeff ForKey: (id) key{
	
	[aberrDict setObject:coeff forKey:key];
	
}




- (void) dealloc
{
	[label release];
	[super dealloc];
}



@end
